package cn.pupil.design;


import cn.pupil.design.impl.doRaffleRandom;
import cn.pupil.design.impl.doRaffleWeight;
import com.alibaba.fastjson.JSON;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 测试验证
 * @Author: pupil
 * @Date: 2024/06/28 下午 5:25
 */
public class ApiTest {
    private Logger logger = LoggerFactory.getLogger(ApiTest.class);

    @Test
    public void test_DrawControl(){
        List<RaffleUser> raffleUserList = new ArrayList<>();
        raffleUserList.add(new RaffleUser("张三", 65));
        raffleUserList.add(new RaffleUser("李四", 43));
        raffleUserList.add(new RaffleUser("王五", 72));
        raffleUserList.add(new RaffleUser("花花", 89));
        raffleUserList.add(new RaffleUser("豆豆", 10));

        RaffleControl raffleControl = new RaffleControl();
        List<RaffleUser> prizeRandomUserList = raffleControl.doRaffle(new doRaffleRandom(),raffleUserList, 3);
        logger.info("随机抽奖，中奖用户名单：{}", JSON.toJSON(prizeRandomUserList));

        List<RaffleUser> prizeWeightUserList = raffleControl.doRaffle(new doRaffleWeight(),raffleUserList, 3);
        logger.info("权重抽奖，中奖用户名单：{}", JSON.toJSON(prizeWeightUserList));
    }
}
